package com.geektime.hello.controller;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.LinkedHashMap;

/**
 * @Author: DRevelation
 * @Date: 2021/8/26 15:25
 */
@RestController
@RequestMapping("json")
public class JsonController {

    @PostMapping("index")
    public String index(@RequestBody JSONObject object) {
        LinkedHashMap<String, String> jsonMap1 = JSON.parseObject(object.toString(), new TypeReference<LinkedHashMap<String, String>>() {
        });
        System.out.println("jsonMap1 = " + jsonMap1);
        return jsonMap1.toString();
    }
}
